package com.enzoism.springboot.dive.bis.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class SchedulerTest {
    /**
     * 使用Timer创建定时器s
     *
     * @param args
     */
    public static void main(String[] args) {
        ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
//        ScheduledExecutorService executorService = new ScheduledThreadPoolExecutor(10);
        executorService.scheduleWithFixedDelay(new MyRunnableTask(), 200, 1000, TimeUnit.MILLISECONDS);
    }

    static class MyRunnableTask implements Runnable {
        @Override
        public void run() {
            System.out.println("------>" + Thread.currentThread().getName() + "定时任务调度");
        }
    }
}
